<%@ page import="com.yueqian.Entity.Employee" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: gaoqiming
  Date: 2025/8/21
  Time: 下午5:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>查询员工信息</title>
</head>
<body>
      <h1>查询员工信息</h1>
          <%
              List<Employee> employees1 = null;
              if (request.getAttribute("employees") != null) {
                  Object employees = request.getAttribute("employees");
                  employees1 = (List<Employee>) employees;
                  %>
         <table>
          <tr>
              <th>员工编号</th>
              <th>员工姓名</th>
              <th>员工密码</th>
          </tr>
          <%
              for (Employee employee : employees1){
          %>
          <tr>
              <td><%=employee.getNumber()%></td>
              <td><%=employee.getUsername()%></td>
              <td><%=employee.getPassword()%></td>
          </tr>
             <%
              }
              }
              %>
          </table>
      <div>
          <a href="page?pageNo=1">首页</a>&nbsp;&nbsp;
          <a href="page?pageNo=${pageIndex-1 }">上一页</a>&nbsp;&nbsp;
          <a href="page?pageNo=${pageIndex+1 }">下一页</a>&nbsp;&nbsp;
          <a href="page?pageNo=${totalPages }">尾页</a>&nbsp;&nbsp;
          跳转到：<input type="text" value="${pageIndex }" style="width:50px" id="num" />页&nbsp;<button onclick="jump()">跳转</button>&nbsp;&nbsp;
          <span>当前第${pageIndex }页;总共${totalPages }页</span>
      </div>
<%--<h1>根据条件查询员工信息</h1>--%>
<%--<form action="GetEmployeeService" method="get">--%>
<%--    <input type="text" name="username" placeholder="请输入员工姓名">--%>
<%--    <input type="text" name="number" placeholder="请输入员工编号">--%>
<%--    <input type="submit" value="查询">--%>
<%--</form>--%>
<%--              <%--%>
<%--              if(request.getAttribute("employee")!=null)--%>
<%--              {--%>
<%--                  Employee employee = (Employee) request.getAttribute("employee");--%>
<%--                  out.print(request.getAttribute("employee"));--%>
<%--              %>--%>
<%--      <table>--%>
<%--          <tr>--%>
<%--              <th>员工编号</th>--%>
<%--              <th>员工姓名</th>--%>
<%--              <th>员工密码</th>--%>
<%--          </tr>--%>
<%--          <tr>--%>
<%--              <td><%=employee.getNumber()%></td>--%>
<%--              <td><%=employee.getUsername()%></td>--%>
<%--              <td><%=employee.getPassword()%></td>--%>
<%--              <a  href="update.jsp?number=<%=employee.getNumber()%>">修改</a>--%>
<%--          </tr>--%>
<%--                <%--%>
<%--                    }else--%>
<%--                  out.print("没有数据");--%>
<%--              %>--%>
<%--<%--%>
<%--    List<Employee> employees1 = null;--%>
<%--    if (request.getAttribute("employees") != null) {--%>
<%--        Object employees = request.getAttribute("employees");--%>
<%--        employees1 = (List<Employee>) employees;--%>
<%--%>--%>
<%--<table>--%>
<%--    <tr>--%>
<%--        <th>员工编号</th>--%>
<%--        <th>员工姓名</th>--%>
<%--        <th>员工密码</th>--%>
<%--    </tr>--%>
<%--    <%--%>
<%--        for (Employee employee : employees1) {--%>
<%--            // 添加空值检查--%>
<%--            if (employee != null) {--%>
<%--    %>--%>
<%--    <tr>--%>
<%--        <td><%=employee.getNumber()%>--%>
<%--        </td>--%>
<%--        <td><%=employee.getUsername()%>--%>
<%--        </td>--%>
<%--        <td><%=employee.getPassword()%>--%>
<%--        </td>--%>
<%--    </tr>--%>
<%--    <%--%>
<%--            }--%>
<%--        }--%>
<%--    %>--%>
<%--</table>--%>

<%--<%--%>
<%--    } else--%>
<%--        out.print("没有数据");--%>
<%--%>--%>
<h1>删除员工</h1>
<form action="DeleteEmployeeService" method="post">
    <input type="text" name="number" placeholder="请输入员工编号">
    <input type="submit" value="删除">
</form>
<%
    String message = (String) request.getAttribute("message");
    if ("请输入员工编号不能为空".equals(message)) {
        out.print(message);
    } else if ("删除员工成功".equals(message)) {
        out.print(message);
    } else if ("删除员工失败".equals(message)) {
        out.print(message);
    } else
        out.print("没有数据");
%>

</body>
</html>
